import { BasicColumn, FormSchema } from '@/components/Table';
import { userRemarkFormItem } from '@/settings/ShareFormItem';
import { render } from '@/utils/common/renderUtils';

export const useCustomerHandleListColumns = (): BasicColumn[] => {
  return [
    {
      title: '主联系人',
      dataIndex: 'primary',
      width: 80,
      customRender: ({ record }) => {
        if (record.primary == 1) {
          return render.renderTag('是', 'success');
        } else {
          return render.renderTag('否', 'error');
        }
      },
    },
    { title: '联系人员', dataIndex: 'name' },
    { title: '联系人电话', dataIndex: 'phone' },
    { title: '联系人地址', dataIndex: 'address' },
    { title: '备注', dataIndex: 'remark' },
  ];
};

export const useCustomerHandleSchemaForm = (): FormSchema[] => {
  return [
    {
      label: '主联系人',
      field: 'primary',
      component: 'Switch',
      componentProps: {
        options: [
          { label: '是', value: 1 },
          { label: '否', value: 0 },
        ],
        checkedChildren: '是',
        unCheckedChildren: '否',
        checkedValue: 1,
        unCheckedValue: 0,
      },
      defaultValue: 1,
    },

    { field: 'name', label: '联系人员', component: 'Input', required: true },

    { field: 'phone', label: '联系人电话', component: 'Input', required: true, labelWidth: 100 },
    { field: 'address', label: '联系人地址', component: 'Input' },
    { field: 'uuid', label: '联系人地址', component: 'Input', show: false },
    userRemarkFormItem(),
  ];
};
